/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.zakariya.stickyheadersapp.page;
import ohos.agp.components.Component;
import ohos.agp.components.ListContainer;
import ohos.app.Context;
import org.zakariya.stickyheaders.Utils;
import org.zakariya.stickyheaders.model.ItemModel;
import org.zakariya.stickyheadersapp.ResourceTable;
import org.zakariya.stickyheadersapp.adapter.StickyAboutAdapter;

import java.util.List;
/**
 * StickyAboutPage
 *
 * @since 2021-08-20
 */
public class StickyAboutPage extends StickyBasePage {
    private Context context;
    private StickyAboutAdapter adapter;

    /**
     * 构造函数
     *
     * @param context 上下文
     */
    public StickyAboutPage(Context context) {
        this.context = context;
    }

    @Override
    void notifyDataChange() {
        if (adapter != null) {
            adapter.notifyDataChanged();
        }
    }

    /**
     * 页面控件初始化
     *
     * @param rootView 根布局
     */
    public void init(Component rootView) {
        ListContainer listContainer = (ListContainer) rootView.findComponentById(ResourceTable.Id_list_about);
        List<ItemModel> dataList = Utils.getAboutList();
        adapter = new StickyAboutAdapter(context, dataList);
        listContainer.setItemProvider(adapter);

    }
}
